package cliproxy

import (
	"gosecond/ch15rpc/newhelloworld/handler"
	"net/rpc"
)

type HelloServiceStub struct {
	*rpc.Client
}

//在go中没有类、对象，就意味着没有初始化方法
func NewHelloServiceClient(protocol, address string) HelloServiceStub{
	conn, err := rpc.Dial(protocol, address)
	if err!=nil{
		panic("connect error!")
	}
	return HelloServiceStub{conn}
}

func (c *HelloServiceStub) Hello(request string, reply *string) error{
	var err error
	err = c.Call(handler.HelloServiceName+".Hello", request, reply)
	return err
}